home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: guerino1@ix.netcom.com(Frank Guerino )
- Newsgroups: comp.lang.c++
- Subject: Inheritance: Accessing members of base classes for assignment in derived classes
- Date: 7 Apr 1996 03:31:52 GMT
- Organization: Netcom
- Message-ID: <4k7cv8$h4m@dfw-ixnews5.ix.netcom.com>
- NNTP-Posting-Host: wfd-nj1-04.ix.netcom.com
- X-NETCOM-Date: Sat Apr 06 9:31:52 PM CST 1996
-
-
- Hi,
-
- I was wondering if someone would know how to translate a specific error
- message I'm getting. I have a base class called "String" which is
- constructed in the following manner:
-
- class String{
- char *str;
- public:
- String() {some initialization code...}
- char *get() { return str; }
- //...}
-
- I have a derived class called "Instruction" which looks as follows:
-
- class Instruction : public String{
- int data;
- public:
- Instruction() {initialization};
- Instruction& operator=(const Instruction& x);
- char *get_instruct() { return String::get(); }
- //... }
-
- I define the operator=() member as follows:
-
- Instruction& Instruction::operator=(const Instruction& x){
- char *tmp;
- strcpy(tmp, x.get_instruct());
- data = x.data;
- return *this;
- }
-
- When I compile, I get the error message:
-
- "cannot conver 'this' pointer from 'const class Instruction *' to
- 'class Instruction *const'
-
- The error points to the "strcpy" statement in the operator=() member
- definition.
-
- Does anyone know what this error means in plain English? ...and how
- to fix it?
-
- BTW, if it matters, I'm using Visual C++ 4.0.
- Extreme thanks!
-
- Frank Guerino
- Guerino1@ix.netcom.com
-